package com.junxonline.instant.common.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 自定义数据权限注解枚举类
 *
 * @author JunX
 * @date 2021-07-12
 */
@Getter
@AllArgsConstructor
public enum DataScopeEnum {

    ALL("全部", 0),
    CUSTOM("自定义", 1),
    ORGANIZATION("本级", 2),
    ORGANIZATION_AND_CHILD("本级及下级", 3),
    SELF("仅自己", 4);


    /**
     * 标签
     */
    private final String label;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 根据value获取枚举类对象
     *
     * @param value value
     * @return OperationEnum
     */
    public static DataScopeEnum getByValue(Integer value) {
        for (DataScopeEnum operationEnum : values()) {
            if (operationEnum.getValue().equals(value)) {
                return operationEnum;
            }
        }
        return null;
    }

    /**
     * 根据value获取枚举类对象的label
     *
     * @param value value
     * @return label
     */
    public static String valuesOf(Integer value) {
        for (DataScopeEnum operationEnum : values()) {
            if (operationEnum.getValue().equals(value)) {
                return operationEnum.getLabel();
            }
        }
        return null;
    }

}
